package com.tbit.main.constant;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

/**
 * @author LMY
 * @create 2022-07-21 9:44
 * 阿里云oss
 */
@Configuration
@RefreshScope
public class AliOssConstant {

    public static String endpoint;

    public static String accessKeyId;

    public static String accessKeySecret;

    public static String bucketName;

    @Value("${tbit-system.oss-endpoint}")
    public void setEndpoint(String endpointS) {
        AliOssConstant.endpoint = endpointS;
    }

    @Value("${tbit-system.oss-accessKeyId}")
    public void setAccessKeyId(String accessKeyIdS) {
        AliOssConstant.accessKeyId = accessKeyIdS;
    }

    @Value("${tbit-system.oss-accessKeySecret}")
    public void setAccessKeySecret(String accessKeySecretS) {
        AliOssConstant.accessKeySecret = accessKeySecretS;
    }

    @Value("${tbit-system.oss-bucketName}")
    public void setBucketName(String bucketNameS) {
        AliOssConstant.bucketName = bucketNameS;
    }

    /**
     * 用于监听到RefreshEvent事件后操作触发创建新实例对象
     */
    public void refresh() {
        System.out.println("刷新配置，触发创建新实例对象");
    }
}
